import service from '../axios/axiosConfigs'
import { Get, Post } from '../type/types'

export const BASE_URL_18089 = 'http://120.53.104.140:18089'

// 封装 get 方法，类型为Get
const get: Get = async (url, config) => {
    let Config = config!
    service.defaults.baseURL = 'http://120.53.104.140:11111'
    const response = await service.get(url, { ...Config });
    return response.data;
};

// 封装 post 方法，类型为Post
const post: Post = async (url, params, config) => {
    let Config = config!
    service.defaults.baseURL = 'http://120.53.104.140:11111'
    const response = await service.post(url, params, { ...Config });
    return response.data;
};

const post8089: Post = async (url, params, config) => {
    let Config = config!
    service.defaults.baseURL = BASE_URL_18089
    //  service.defaults.baseURL = 'http://192.168.0.100:8089' 
    const response = await service.post(url, params, { ...Config });
    return response.data;
};

const post18089: Post = async (url, params, config) => {
    let Config = config!
     service.defaults.baseURL = BASE_URL_18089
    const response = await service.post(url, params, { ...Config });
    return response.data;
};

// 使用 request 统一调用
const request = {
    get,
    post,
    post8089,
    post18089
};

export default request;